<?php
class daywidget extends select {
	protected $validdays = array(28,29, 30, 31);
	public $numdays = 31;
	
	public function __construct($dayofmonth = ''){
		parent::__construct();
		if ( strlen($dayofmonth) && is_numeric($dayofmonth)){
			$this->setSelected($dayofmonth);
		}
	}

	public function __toString(){
		if ( ! in_array($this->numdays, $this->validdays)){
			$this->numdays =31;
		}
		for ( $i = 1; $i <= $this->numdays; $i++ ){
			$this->values[$i] = $i;
		}
		return parent::__toString();
	}

	public function setNumDays($num = ''){
		if( strlen($num) && in_array($num, $this->validdays)){
			$this->numdays = $num;
		}
	}
}
?>